import request from '@/axios';

export const getList = (current, size, params) => request({
  url: '/zzy-develop/model/list',
  method: 'get',
  params: {
    ...params,
    current,
    size,
  },
});

export const getDetail = id => request({
  url: '/zzy-develop/model/detail',
  method: 'get',
  params: {
    id,
  },
});

export const remove = ids => request({
  url: '/zzy-develop/model/remove',
  method: 'post',
  params: {
    ids,
  },
});

export const add = row => request({
  url: '/zzy-develop/model/submit',
  method: 'post',
  data: row,
});

export const update = row => request({
  url: '/zzy-develop/model/submit',
  method: 'post',
  data: row,
});

export const getTableList = datasourceId => request({
  url: '/zzy-develop/model/table-list',
  method: 'get',
  params: {
    datasourceId,
  },
});

export const getTableInfo = (modelId, datasourceId) => request({
  url: '/zzy-develop/model/table-info',
  method: 'get',
  params: {
    modelId,
    datasourceId,
  },
});

export const getTableInfoByName = (tableName, datasourceId) => request({
  url: '/zzy-develop/model/table-info',
  method: 'get',
  params: {
    tableName,
    datasourceId,
  },
});

export const getModelPrototype = (modelId, datasourceId) => request({
  url: '/zzy-develop/model/model-prototype',
  method: 'get',
  params: {
    modelId,
    datasourceId,
  },
});

export const submitModelPrototype = row => request({
  url: '/zzy-develop/model-prototype/submit-list',
  method: 'post',
  data: row,
});

export const prototypeDetail = modelId => request({
  url: '/zzy-develop/model-prototype/select',
  method: 'get',
  params: {
    modelId,
  },
});
